﻿<UserControl x:Class="TrixPlugin.Common.StrategyControl"
			 x:ClassModifier="internal"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
			 xmlns:Trix="clr-namespace:TrixPlugin.Common" xmlns:System="clr-namespace:System;assembly=mscorlib"

             mc:Ignorable="d"
			 
             Background="#1F1F1F"

             d:DesignHeight="130" 
             d:DataContext="{d:DesignInstance Type=Trix:StrategyControlVM}" >

	<UserControl.Resources>
		<ResourceDictionary>
			<Converters:MultiplierConverter x:Key="MultiplierConverter" />
			<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="OperationMode">
				<ObjectDataProvider.MethodParameters>
					<x:Type TypeName="Trix:OperationMode" />
				</ObjectDataProvider.MethodParameters>
			</ObjectDataProvider>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/Plugins;component/PluginTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
			
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!-- Header -->
		<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Text="Execution Parameters" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="Header" Margin="6" />
		
		<!-- Settings -->
		<TextBlock Grid.Row="1" Grid.Column="0" Margin="3,3,6,3" Text="Working Mode" />
		<ComboBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" ItemsSource="{Binding Source={StaticResource OperationMode}}" SelectedItem="{Binding WorkingMode, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=1}" >
			<ComboBox.Resources>
				<Style TargetType="TextBlock">
					<Style.Triggers>
						<Trigger Property="IsEnabled" Value="True">
							<Setter Property="Foreground" Value="Black" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</ComboBox.Resources>
		</ComboBox>
		
		<TextBlock Grid.Row="3" Grid.Column="0" Margin="3,3,6,3" Text="Trix Period" />
		<TextBox Grid.Row="3" Grid.Column="1" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding TrixPeriod, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Trix Period" />
					<TextBlock Foreground="Black" Text="The period used to calculate trix." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		<TextBlock Grid.Row="3" Grid.Column="2" Margin="3,3,6,3" Text="bars" />
		
		<TextBlock Grid.Row="4" Grid.Column="0" Margin="3,3,6,3" Text="Bar Period" />
		<TextBox Grid.Row="4" Grid.Column="1" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding BarPeriod, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Bar Period" />
					<TextBlock Foreground="Black" Text="The period used to calculate trix bar's source." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		<TextBlock Grid.Row="4" Grid.Column="2" Margin="3,3,6,3" Text="seconds" />
		
		<!-- Internal Separator -->
		<Border Grid.Row="1" Grid.Column="4" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

		<TextBlock Grid.Row="2" Grid.Column="5" Margin="3,3,6,3" Text="Inverted" VerticalAlignment="Center" />
		<CheckBox Grid.Row="2" Grid.Column="6" Margin="3,3,6,3" IsChecked="{Binding Inverted}" VerticalAlignment="Center" >
			<CheckBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Invert" />
					<TextBlock Foreground="Black" Text="Inverts the working mode, when a buy should be done a sell is executed and the other way around" />
				</StackPanel>
			</CheckBox.ToolTip>
		</CheckBox>

		<TextBlock Grid.Row="3" Grid.Column="5" Margin="3,3,6,3" Text="Volume" />
		<TextBox Grid.Row="3" Grid.Column="6" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding Volume, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Volume" />
					<TextBlock Foreground="Black" Text="The volume to be bought or sold at each operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

		<TextBlock Grid.Row="4" Grid.Column="5" Margin="3,3,6,3" Text="Stop Loss" />
		<TextBox Grid.Row="4" Grid.Column="6" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding StopLoss, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Stop Loss" />
					<TextBlock Foreground="Black" Text="The max loss before exitting a position" />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

	</Grid>
</UserControl>